****************************************************************************
*** Replication code for "Algorithmic Aversion? Experimental Evidence on ***
*** the Elasticity of Public Attitudes to "Killer Robots" by Ondrej      ***
*** Rosendorf, Michal Smetana, and Marek Vranka                          ***
****************************************************************************

*** Instructions for replication ***

* The code was written in Stata 17.0 BE-Basic Edition
* Please reach out to ondrej.rosendorf@fsv.cuni.cz if you have any questions concerning this replication file
* IMPORTANT: This file is accompanied by the ss_replication_data2 dataset
* Before proceeding with the replication, please make sure that the "asdoc" and "estout" package is installed

* To install the asdoc package, use the following command
ssc install asdoc, replace

* To install the estout package, use the following command
ssc install estout, replace

* Setting the output scheme to black and white
set scheme s1mono

***************************************************
*** Replication of the results in the main text ***
***************************************************

*** Figure 3 (margins plot) - predictive margins of risk estimate difference on LAWS preference ***

* Running the logistic regression
logistic preference estdif

* Obtaining the margins
margins, at(estdif=(-100(1)100))

* Plotting the margins
marginsplot, xlabel(-100(20)100) recast(line) recastci(rarea) ciopt(color(%25)) xtitle("Risk estimate difference") ytitle("Probability of LAWS preference") title("")

* Exporting the graph (Figure 3)
graph export F03.png

************************************************
*** Replication of the results in Appendix 8 ***
************************************************

*** Appendix 8, Table 1 - paired t-test of risk estimates ***

* Running the paired t-test
* Note 1: the "==" operator specifies that the t-test is of the paired variant
* Note 2: the "asdoc" command allows generating a word document with the results (Appendix 8, Table 1)
asdoc ttest estaut==estrem, replace title(Table 1: Paired t-test of risk estimates) save(A08T01)

*** Appendix 8, Table 2 - logistic regression of LAWS preference (DV), risk estimate difference (IV) ***

* Running the logistic regression
logistic preference estdif

* Storing the estimates (Model 1)
estimates store A08T01M01

* Generating a table (Appendix 8, Table 2)
esttab A08T01M01 using A08T02.rtf, noeqlines eqlabels(none) eform nogaps se pr2 varlabels(estdif "Risk estimate difference" _cons "Constant") mtitle("LAWS preference") title(Table 2: Logistic regression of LAWS preference) nonumbers mlabels("Model 1")

**********************************************
*** Continue with rsv_ss_replication_code3 ***
**********************************************